<?php

class ContactForm extends BaseForm
{
  public function configure()
  {
    $this->setWidgets(array(
      'name'    => new sfWidgetFormInputText(),
      'email'   => new sfWidgetFormInputText(),
      'phone'   => new sfWidgetFormInputText(),
      'message' => new sfWidgetFormTextarea(),
    ));
    
    $this->widgetSchema->setLabels(array(
      'name'    => 'Name',
      'email'   => 'E-Mail',
      'phone'   => 'Phone',
      'message' => 'Message',
    ));
    
    $this->setValidators(array(
      'name'  => new sfValidatorString(
              array('required' => true), 
              array('required' => 'Your name is required')),
      'email' => new sfValidatorEmail(
              array('required' => true),
              array(
                  'required' => 'An email is required',
                  'invalid' => 'The email format is incorrect'
                  )),
      'phone' => new sfValidatorRegex(
              array(
                  'required' => true,
                  'pattern' => '/^[0-9]{10}$/'),
              array(
                  'required' => 'Your phone number is required',
                  'invalid' => 'The phone number must have 10 numbers only'
                  )),
      'message' => new sfValidatorString(
              array(
                  'required' => true,
                  'min_length' => 4,
                  ),
              array(
                  'required' => 'You have to type a message',
                  'min_length' => 'Your message is too short'
                  )),
    ));
    
    $this->widgetSchema->setNameFormat('contact[%s]');
    
    //$this->embedI18n(array('en', 'es'));
    
    //$this->setDefaults(array('name' => 'Ingrese su Nombre', 'email' => 'Ingrese su Email'));
  
  }
}